package moe.kotake.webbehw.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

@Data
@Schema(name = "用户")
public class user {
    @TableId(type = IdType.AUTO)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @JsonView(userSimpleView.class)
    private Long id;

    @NotBlank
    @Size(min = 1, max = 20,message = "用户名在1-20位之间")
    @JsonView(userSimpleView.class)
    private String name;

    @NotBlank
    @Size(min = 4, max = 20,message = "密码在4-20位之间")
    @JsonView(userDataView.class)
    private String password;

    @NotBlank
    @JsonView(userSimpleView.class)
    private String email;

    private String friends;

    public interface userSimpleView{};
    public interface userDataView extends userSimpleView{};

    public user(Long _id,String _name,String _pswd,String _email)
    {id=_id;name = _name;password = _pswd;email = _email;}
    public user(Long _id)
    {id=_id;}
    public user() {}

}
